import { Provide } from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { MagicEntity } from '../../entity/magic';
import { MagicService } from '../../service/magic';
import { Context } from 'egg';
/**
 * 商品
 */
@Provide()
@CoolController({
  // 添加通用CRUD接口
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  // 设置表实体
  entity: MagicEntity,
  service: MagicService,
  // 新增的时候插入当前用户ID
  insertParam: async (ctx: Context) => {
    return {
      userId: ctx.admin.userId,
    };
  },
  pageQueryOp: {
    // 让title字段支持模糊查询
    keyWordLikeFields: ['title', 'magic_key', 'source'],
    fieldEq: ['title', 'magic_key', 'source'],
  },
})
export class MagicController extends BaseController {}
